package cate.game.server.service.process;

import cate.game.table.TableManager;
import cp.solution.define.SrvType;
import cp.solution.pattern.Feedback;
import easy.java.runtime.JvmInfo;
import easy.java.struct.ref.StringRef;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

@Slf4j
public class ProcessCmds {

    public static StringRef jvmInfo(StringRef msg) {
        JvmInfo ji = new JvmInfo();
        ji.setLogEnabled(false);
        return new StringRef(ji.printAll());
    }

    public static StringRef jvmGc(StringRef msg) {
        System.gc();
        return new StringRef("已执行GC");
    }

    public static Feedback reloadExcel(String excel) {
        log.info("收到ConsoleServer重载excelの请求：excel参数={}", excel);
        Feedback feedback = new Feedback().start();
        TableManager.instance.reload(excel);
        String info = "重载excel完成";
        if(StringUtils.isBlank(excel)) {
            info += "(全部)";
        } else {
            info += "(仅针对"+excel+")";
        }
        return feedback.text(info).stop();
    }
}
